<template>
	<view class="">
		<view class="head">
			<TbarNav class="topNav" title="游艇详情"  is_back isbg="0" :stickys="false" :barStyle="{ background:'transparent',color:'#fff'}">
				<template #left>
					<view class="back-warp">
						<image @click="go"
							   :src="baseUrl + '/static/wximages/arrow-pointing-to-righi'+ '' +'.png'" 
							   >
						</image>
					</view>
				</template>
			</TbarNav>
			
			<view class="swiper-box">
				<swiper class="swiper-warp" :current="currentIndex" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000"
				@change="swiperChange"
				>
					<swiper-item class="swiper-item-warp"  v-for="(item,index) in swiperList" :key="index">
						<image class="swiper-item" style="color: #fff;" :src="item" @click="previewImg(item)">
							<!-- <image src="" mode=""></image> -->
							<!-- <video src="" controls></video> -->
						</image>
					</swiper-item>
				</swiper>
				<!-- 轮播点 -->
				<view class="indicator-warp">{{ currentIndex+1 }}/{{swiperList.length}}</view>
			</view>
			
			<view class="hot-txt">
				<text class="h-right">享好价 超安心</text>
				<text class="h-center">|</text>
				<text class="h-left">省心租 · 无忧退</text>
			</view>
			
			<view class="detail-warp">
				<view class="show-info">
					<itemInfoComp style="height: 100%;" :itemInfo="info"></itemInfoComp>
					<view class="prize">￥<text style="font-weight: 700;font-size: 40rpx;">{{ info.price }}</text>/时</view>
				</view>
				
				<!-- 地理位置区域 -->
				<locationInfo :address="addressInfo"></locationInfo>
				<!-- 海报区域 -->
				<view class="post-image">
					<!-- <image  :src="info.image_input" mode="aspectFill"></image> -->
					<parser :html="info.content" ref="article" :tag-style="tagStyle"></parser>
				</view>
				
				<itemUlComp style="margin-top: 38rpx;" title="预定须知" :list="[
					'游艇荷载人数严格限制（8~12人），儿童及婴儿均占位。部分项目需签署免责协议（如自驾摩托艇）',
					'预定以定金为准，余款需登船前结清']"
				></itemUlComp>
				<itemUlComp title="价格说明" :list="[
					'50~80尺游艇包船价格为800~1200元/3小时，80尺以上起价1200元/3小时',
					'豪华100尺游艇包船3小时费用包含保险、餐食及娱乐设施，需提前确认船期'
				]"></itemUlComp>
				<itemUlComp title="服务内容" :list="[
					`<view style='color:#000'>基础服务：</view>船长、水手、救生设备、保险`,
					`<view style='color:#000'>附加内容：</view>水果拼盘、饮料、渔具、滑梯、浮潜工具等`,
					`<view style='color:#000'>特色体验：</view>部分游艇提供KTV、驾驶体验、海上商务会所服务`
				]"></itemUlComp>
			</view>
			<button class="submit" @click="onSubmit">立即预定</button>
			<!-- <view class="img">
				<image :src="info.image_input" mode="widthFix"></image>
			</view>
			<view class="title">
				<text>{{info.title}}</text>
			</view> -->
		</view>
		
		
		<!-- <view class="desc">
			<view class="title">
				<text>详情介绍</text>
			</view>
			<view class="desc-txt">
				<parser :html="info.content" ref="article" :tag-style="tagStyle"></parser>
			</view>
		</view>
		<view style="height: 152rpx;"></view>
		<view class="btns">
			<button class="xy" @click="setProjectCollect">
				<image :src="baseUrl +'/static/wximages/icon-15'+ (collectInfo ? '-01': '')  +'.png'" mode="widthFix"></image>
				<text>想要</text>
			</button>
			<button class="submit" @click="onSubmit">立即预约</button>
		</view> -->
	</view>
</template>

<script>
	import TbarNav from '@/components/TbarNav'
	import { storeListApi } from '@/api/store.js';
	import { getProjectInfo, getProjectCollectInfo, setProjectCollect } from '@/api/reserve.js';
	import parser from '@/components/jyf-parser/jyf-parser';
	import itemInfoComp from '@/pages/index/comp/itemInfoComp.vue'
	import itemUlComp from '@/pages/index/comp/itemUlComp.vue'
	import locationInfo from '@/pages/reserve/comp/locationInfo.vue'
	export default {
		components: {
			TbarNav,
			parser,
			itemInfoComp,
			itemUlComp,
			locationInfo
		},
		data() {
			return {
				baseUrl: this.$baseUrl,
				id: '',
				info: {},
				collectInfo: null,
				currentIndex:0,
				swiperList:[],
				tagStyle: {
					height:'800rpx',
					img: 'width:100%;display:block;',
					table: 'width:100%',
					video: 'width:100%;height:100%;'
				},
				addressInfo:''
			}
		},
		computed:{
			contentImage(){
				return ''
			}
		},
		onLoad(ops) {
			if (ops.id) {
				this.id = ops.id;
			}
		},
		onShow() {
			this.getProjectCollectInfo()
			this.getProjectInfo();
			this.getList()
		},
		methods: {
			swiperChange(e){
				console.log('e=======>',e);
				const { detail } =e
				this.currentIndex = detail.current
			},
			previewImg(item){
				console.log(item);
				uni.previewImage({
					urls:[item.image_input]
				})
			},
			getProjectInfo() {
				getProjectInfo({id: this.id}).then(res => {
					this.info = res.data;		
					this.swiperList = [res.data.image_input]
					if (this.info.content) {
						this.info.content = this.info.content.replace(/<img/gi, '<img style="max-width:100%;height:auto;float:left;display:block" ');
						this.info.content = this.info.content.replace(/<video/gi, '<video style="width:100%;height:300px;display:block" ');
					}
					
				})
			},
			getList() {
				let longitude = uni.getStorageSync("user_longitude") || ''; //经度
				let latitude = uni.getStorageSync("user_latitude") || ''; //纬度
				let data = {
					latitude: latitude, //纬度
					longitude: longitude, //经度
					page: 1,
					limit: 10
				}
				storeListApi(data).then(res => {
					console.log('res============>',res);
					let list = res.data.list.list || [];
					const { address,detailed_address,name } = list[0]|| {}
					const arr = address.split(',')
					this.addressInfo = arr[0] + name + detailed_address
				}).catch(err => {})
			},
			getProjectCollectInfo() {
				getProjectCollectInfo({cid: this.id}).then(res => {
					
					if (res.data) {
						this.collectInfo = res.data;
					} else {
						this.collectInfo = null;
					}
				})
			},
			setProjectCollect() {
				setProjectCollect({cid: this.id}).then(res => {
					this.getProjectCollectInfo()
				})
			},
			onJmup(url) {
				uni.navigateTo({
					url: url
				})
			},
			onSubmit() {
				uni.navigateTo({
					url: '/pages/reserve/project/order?id='+this.info.id
				})
			},
			go() {
				var routes = getCurrentPages();
				if (routes.length > 1) {
					uni.navigateBack();
				} else {
					uni.switchTab({
						url: '/pages/card/index'
					})
				}
			}
		}
	}
</script>
<style>
	page {
		/* background: #003153; */
		background: #fff;
	}
	
</style>
<style scoped lang="scss">
	::v-deep .topNav{
		.title{
			color: #fff;
		}
	}
	.back-warp{
		width: 56rpx;
		height: 56rpx;
		border-radius: 50%;
		overflow: hidden;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: rgba(193, 193, 193, 0.5);
		margin-left: 20rpx;
		image{
			width: 80%;
			height: 80%;
		}
	}
	.head {
		width: 100%;
		.swiper-box{
			width: 100%;
			height: 592rpx;
			position: relative;
			background: #003153; 
			.swiper-warp{
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				.swiper-item-warp{
					width: 100%;
					height: 100%;
					.swiper-item{
						width: 100%;
						height: 100%;
					}
				}
				
			}
			.indicator-warp{
					position: absolute;
					right: 22rpx;
					bottom: 76rpx;
					width: 88rpx;
					height: 48rpx;
					border-radius: 24rpx;
					text-align: center;
					line-height: 48rpx;
					color:#fff;
					font-size: 32rpx;
					background-color: rgba(0, 0, 0, .4);
			}
		}
		
		.hot-txt{
			width: 100%;
			height: 66rpx;
			background: #fdedd9;
			line-height: 66rpx;
			padding: 0 22rpx;
			box-sizing: border-box;
			border-radius: 44rpx 44rpx 0rpx 0rpx;
			margin-top: -50rpx;
			position: relative;
			.h-right{
				color:rgba(254, 89, 0, 1) ;
				font-weight: 700;
				font-size: 30rpx;
			}
			.h-center,.h-left{
				color:rgba(254, 89, 0, .8);
				font-weight: 400;
			}
			.h-center{margin: 0 20rpx;}
		}
		
		.detail-warp{
			width: 100%;
			min-height: 800rpx;
			padding: 28rpx 22rpx;
			box-sizing: border-box;
			.show-info{
				height: 140rpx;
				display: flex;
				justify-content: space-between;
				.prize{
					margin-top: 20rpx;
					font-weight: 300;
					font-size: 22rpx;
					color: #FE5900;
				}
			}
			
			
			.post-image{
				width: 100%;
				// height: 898rpx;
				min-height: 120rpx;
				// background: #D8D8D8;
				image{
					width: 100%;
					height: 100%;
					vertical-align: top;
				}
			}
		}
		
		.submit {
			width: 100%;
			height: 182rpx;
			background: #2456FF;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			text-align: center;
			line-height:  182rpx;
			border-radius: 0;
		}
		
		
		
		// .img {
		// 	image {
		// 		width: 750rpx;
		// 		height: auto;
		// 		border-radius: 0rpx 0rpx 0rpx 0rpx;
		// 	}
		// }
		// .title {
		// 	width: 100%;
		// 	padding: 25rpx;
		// 	font-weight: 400;
		// 	font-size: 35rpx;
		// 	color: #FFFFFF;
		// 	text {
		// 		-webkit-line-clamp: 2;
		// 		display: -webkit-box;
		// 		-webkit-box-orient: vertical;
		// 		overflow: hidden;
		// 		text-overflow: ellipsis;
		// 	}
		// }
	}
	
	.desc {
		.title {
			font-weight: 400;
			font-size: 30rpx;
			color: #FFFFFF;
			padding: 35rpx;
			text-align: center;
		}
	}
	
	
	.btns {
		height: 152rpx;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		background: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 25rpx;
		.xy {
			flex: 0 0 80rpx;
			width: 80rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: 20rpx;
			color: #003153;
			margin-right: 30rpx;
			image {
				width: 40rpx;
				height: 40rpx;
				margin-bottom: 10rpx;
			}
		}
		.submit {
			width: 590rpx;
			height: 83rpx;
			background: #003153;
			border-radius: 5rpx 5rpx 5rpx 5rpx;
			font-weight: 400;
			font-size: 28rpx;
			color: #FFFFFF;
			text-align: center;
			line-height:  80rpx;
		}
	}
</style>